import React, {Component, PropTypes} from 'react';
import {Row, Col, Card, Input, Button, Icon} from 'antd';
import styles from './Main.less';
import {login} from "../../services/authServer";


class LoginMainContainer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {
  }

  componentWillMount() {
    this.loginOnClick();
  }

  componentWillUnmount() {
  }

  loginOnClick() {

    const client_id = "7af5f492a74499e7";//dev
    // const client_id = "55e79c13403cd1c8";//dist
    const callbackUrl = "http://192.168.18.71:8989/callback";
    // const callbackUrl = "http://192.168.8.198:8989/callback";

    const authServer = "http://192.168.8.198";
    const authURL = authServer + "/auth/jjOAuthv1.0";
    const open_url = authURL + "/open.php";

    window.location.href = open_url + '?' +
      'response_type=code&' +
      'client_id=' + client_id + '&' +
      'state=xyz&redirect_uri=' + callbackUrl;
  }

  render() {
    return (
      <div className={styles.login_center}>
        <Row>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <Col span={24} style={{textAlign: "center"}}>
            <br/>
            <Card title={
                <span style={{fontFamily: '微软雅黑', fontSize: '20px', fontWeight: 'bold', color: '#000'}}><Icon type="user"/>用户登录</span>
            } style={{width: 350}}>
              {/*<Row>*/}
              {/*<Col span={24} style={{textAlign: "center"}}>*/}
              {/*<Input addonBefore={<Icon type="user"/>} placeholder="用户名"/>*/}
              {/*</Col>*/}
              {/*</Row>*/}
              {/*<br/>*/}
              {/*<Row>*/}
              {/*<Col span={24} style={{textAlign: "center"}}>*/}
              {/*<Input addonBefore={<Icon type="lock"/>} placeholder="密码"/>*/}
              {/*</Col>*/}
              {/*</Row>*/}
              <Row>
                <Col span={24}>
                  <Button type="primary" onClick={this.loginOnClick}>
                    <span style={{fontFamily: '微软雅黑', fontSize: '12px'}}>LDAP账号登录</span>
                  </Button>
                </Col>
              </Row>
            </Card>
          </Col>
        </Row>
      </div>
    );
  }
}

export default LoginMainContainer;
